<?php
/**
 * 状态
 * 
 * @package ews
 * @ews Enterprise WorkShop
 * @version 1.0 alpha
 * @since 2011-05-13
 * @author monkee
 */

class doingApp extends app
{
	function __construct(){
		$this->_init();
		$this->login_need();
	}
	public function view(){
		$doing_id = $this->getData('post/doingid');
		$doing_id = intval($doing_id);
		$doingobj = & $this->getModel('doing');
		$doing = $doingobj->get($doing_id);
		$replyobj = & $this->getModel('reply');
		return array(
			'doing' => $doing,
			'reply' => $replyobj->get_replys(1, $doing_id),
			'username' => $this->user['username']
		);
	}
	/**
	 * 用户添加状态
	 * 
	 */
	public function add(){
		$doing = & $this->getModel('doing');
		$message= & $this->getData('post/message');
		$message = trim($message);
		if(empty($message)){
			return array('code' => 0);
		}
		$doing_id = $doing->update($this->user_id, $message);
		//建立model
		$model = & $this->getModel('model');
		$model_id = $model->create($this->user_id, $this->user['username'], $doing_id, 'doing', $message, $message);
		//发布feed
		$feed = & $this->getModel('feed');
		$feedid = $feed->add($this->user_id, $message, $model_id);
		$html = '<li><div class="avatar"><img src="'.get_avatar($this->user_id).'" width="50"></div>';
		$html .= '<div class="feed-body">';
		$html .= '<a href="javascript:void(0);">'.$this->user['username'].'</a>&nbsp;:&nbsp;'.$message.'</div>';
		$html .= '<div class="func" feedid="'.$feedid.'" state="0"><a href="#">加标签</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#">分享</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a id="a'.$model_id.'" href="javascript:void(0);" onclick="unfoldComment('.$model_id.')" class="folded">评论</a></div>';
		$html .= '<div class="comment"></div>';
		$html .= '</li>';
		$html = 'hello,world';
		return array('code' => 1, 'html' => $html);
	}
}
?>
